<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;


/**
 * App\OrderItem
 *
 * @property int $id 自增id
 * @property int $order_id 订单id
 * @property int $merchant_medicine_id 药品id
 * @property int $merchant_medicine_spu_id 商品属性id
 * @property string|null $item_num 子订单编号
 * @property float $original_price 商品原始单价
 * @property float $discount_price 商品优惠后单价
 * @property int $num 购买数量
 * @property float $total_amount 实际成交总价格
 * @property int $goods_snapshot_id 快照id
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\OrderItem onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereDiscountPrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereGoodsSnapshotId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereItemNum($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereMerchantMedicineId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereMerchantMedicineSpuId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereNum($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereOrderId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereOriginalPrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereTotalAmount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\OrderItem withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\OrderItem withoutTrashed()
 * @mixin \Eloquent
 * @property int $goods_id 商品id
 * @property int $goods_spu_id 商品属性id
 * @property string $goods_ssn 商品货号
 * @property int $status 子订单状态 0：未评价 1：已评价
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereGoodsId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereGoodsSpuId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereGoodsSsn($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\OrderItem whereStatus($value)
 */
class OrderItem extends Model
{
    protected $table='order_item';
    use SoftDeletes;

    public static function getOrderItem($order_id){
        $data=self::whereOrderId($order_id)->get();
        if (count($data) > 0){
            foreach ($data as $item){
                $item->medicine_info=MerchantMedicine::getMedicineListItemInfo($item->merchant_medicine_id);
            }
        }
        return $data;
    }
}
